#include "url_defines.h"
#include "base/format_macros.h"
#include "base/stringprintf.h"

namespace dl {
using namespace net;

const char kRequestSymbol[] = "request_symbol";

const wchar_t kUndownExtension[] = L".apptdl";

HttpRequestHeaders ResolveRequestExtraHeaders(const URLRequestData& data) {
  HttpRequestHeaders headers;
  if (data.start_position > 0) {
    headers.SetHeader(HttpRequestHeaders::kRange,
                      base::StringPrintf("bytes=%" PRIuS "-",
                                         data.start_position));
  }
  return headers;
}

int64 ResolveStartPositionFromResponseHeaders(const HttpResponseHeaders& headers) {
  int64  start_position(0), end_position(0), instance_length(0);
  headers.GetContentRange(&start_position, &end_position, &instance_length);
  return (start_position > 0) ? start_position : 0;
}

}
